package airplane.obj;

import airplane.war.GameWin;

import java.awt.*;

// 游戏元素父类
public class GameObj {
    // 物体的图片
    Image imag;
    // 物体的x坐标
    int x;
    // 物体的y坐标
    int y;
    // 物体的宽度
    int width;
    // 物体的高度
    int height;
    // 物体的移动速度
    int speed;
    // 窗口的引用
    GameWin gameWin;

    public Image getImag() {
        return imag;
    }

    public void setImag(Image imag) {
        this.imag = imag;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public int getSpeed() {
        return speed;
    }

    public void setSpeed(int speed) {
        this.speed = speed;
    }

    public GameWin getGameWin() {
        return gameWin;
    }

    public void setGameWin(GameWin gameWin) {
        this.gameWin = gameWin;
    }

    public GameObj() {
    }

    public GameObj(Image imag, int x, int y, int speed) {
        this.imag = imag;
        this.x = x;
        this.y = y;
        this.speed = speed;
    }

    public GameObj(Image imag, int x, int y, int width, int height, int speed) {
        this.imag = imag;
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
        this.speed = speed;
    }

    public GameObj(Image imag, int x, int y, int speed, GameWin gameWin) {
        this.imag = imag;
        this.x = x;
        this.y = y;
        this.speed = speed;
        this.gameWin = gameWin;
    }

    public GameObj(Image imag, int x, int y, int width, int height, int speed, GameWin gameWin) {
        this.imag = imag;
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
        this.speed = speed;
        this.gameWin = gameWin;
    }

    // 绘制自身的方法
    public void paintSelf(Graphics graphics) {
        graphics.drawImage(imag, x, y, width, height, null);
    }
    // 获取自身矩形的方法
    public Rectangle getRec() {
        return new Rectangle(x, y, width, height);
    }
}
